//
//  testView.m
//  xibDemo
//
//  Created by wanglei on 17/2/4.
//  Copyright © 2017年 wanglei. All rights reserved.
//

#import "testView.h"

@interface testView ()

@end


@implementation testView


// 对应UIView的xib代码方法入口
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupXib];
    }
    return self;    
}


// 对应UIview的xib的入口方法
- (instancetype)initWithCoder:(NSCoder *)aDecoder{
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self setupXib];
    }
    return self;
}

- (void)setupXib{
    
   [[NSBundle mainBundle]loadNibNamed:NSStringFromClass([self class]) owner:self options:nil];
    self.testView.backgroundColor = [UIColor yellowColor];
    [self addSubview:self.testView];
    NSLog(@"这里调用了testView的xib");
}

- (void)drawRect:(CGRect)rect {
//    self.testView.frame = CGRectMake(0, 20, 200, 200);
    
    self.testView.frame = self.bounds;
}


@end
